18. A Note about JSON

A Note about JSON

What is JSON and why is JSON linting important.

What is JSON?

JavaScript Object Notation. JSON is a popular and simple format for storing and transferring nested or hierarchal data. It's so popular that most other programming languages have libraries capable of parsing and writing JSON (like Python's JSON library). Internet GET and POST requests frequently pass data in JSON format. JSON allows for objects (or data of other types) to be easily encapsulated within other objects. See the MDN or JSON.org for more details.

This is a fantastic deep dive from Jason Lengstorf about JSON and its ubiquitous use in the form of AJAX requests.

Why should I lint my JSON?

With a mix of nested curly braces, square brackets and commas, it's easy to make mistakes with JSON. And mistakes mean bugs. Seriously, I mess up JSONs all the time. You might even be able to spot a bug in one of my JSONs in a video in this courseā€¦

If you're generating JSON by hand, you should copy and paste your code into a JSON linter like jsonlint.com to quickly and easily find syntax errors. A linter is a piece of software that analyzes code for syntax errors. Some text editors, like Sublime Text, will automatically lint (or highlight) most syntax errors. But a JSON linter won't miss any syntax errors and you can rest assured that your JSONs will be properly formatted.

Click "Next" to dive into JSON!

INSTRUCTOR NOTE:


Important Note:

For the Online Resume project you'll be using javaScript Object Literals rather than JSON to define your objects. The syntax is very similar, but javaScript Object Literals permit the inclusion of functions as properties and JSON does not.



Follow your instructors!

@cwpittman

+jameswilliams